/*
 * Copyright (c) 2017年11月07日  by XuanWu Wireless Technology Co., Ltd 
 *             All rights reserved  
 */
package com.zml.third.javaio;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * @author <a href="mailto:zhaominglin@wxchina.com">minglin.Zhao</a>
 * @Description
 * @Date 2017/11/7
 * @Version 1.0.0
 */
public class LowerCaseInputStream extends FilterInputStream {
    public LowerCaseInputStream(InputStream in){
        super(in);
    }
    @Override
    public int read() throws IOException {
        int c = super.read();
        return (c == -1 ? c : Character.toLowerCase(c));
    }

    @Override
    public int read(byte[] b,int offset, int len) throws IOException {
        int result = super.read(b,offset,len);
        for(int i = offset;i<offset+result; i++){
            b[i] =(byte)Character.toLowerCase((char)b[i]);
        }
        return result;
    }
}
